package com.hhhn.wk.main.tab4.abuot;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.hhhn.wk.R;
import com.hhhn.wk.base.BaseActivity;
import com.hhhn.wk.utils.AllPublic;
import com.hhhn.wk.utils.Constants;
import com.hhhn.wk.utils.ToastUtils;
import com.hhhn.wk.widget.dialog.ActionSheet;

/**
 * * * * * * * * * * * *
 * @author：文珂    ｡◕‿◕｡ *
 * Data：2018/1/2 0002    ｡◕‿◕｡ *
 * Function：      ｡◕‿◕｡ *
 * 关于
 * * * * * * * * * * * */
public class AboutActivity extends BaseActivity  implements ActionSheet.OnActionSheetSelected, DialogInterface.OnCancelListener {

    private TextView tv_versionName;
    private TextView tv_title;
    private LinearLayout ll_userAgreement;
    private LinearLayout ll_CompanyIntroduction;
    private LinearLayout ll_call;
    private Context context;
    private BaseActivity activity;
    @Override
    protected void setOnCreateContentView() {
        setContentView(R.layout.activity_about);
        context=AboutActivity.this;
        activity=this;
    }
    @Override
    protected void initView() {
        tv_versionName=findViewById(R.id.tv_versionName);
        tv_title=findViewById(R.id.tv_title);
        ll_userAgreement=findViewById(R.id.ll_userAgreement);
        ll_CompanyIntroduction=findViewById(R.id.ll_CompanyIntroduction);
        ll_call=findViewById(R.id.ll_call);
    }
    @Override
    protected void initData() {
        tv_title.setText("关于我们");
        PackageManager packageManager = context.getPackageManager();
        try {
            PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
           String versionname = packInfo.versionName;
            tv_versionName.setText("V"+versionname);
//            System.out.println("#$%%$##$%%$##$%^%$#$%#$%$$%=="+versionname+"=="+packInfo.versionCode);
        } catch (PackageManager.NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return ;
        }
    }
    @Override
    protected void initClick() {
        ll_userAgreement.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                startActivity(new Intent(context,UserAgreementActivity.class));
                AllPublic.linkH5(activity, activity,"用户协议", Constants.userAgreement);
            }
        });
        ll_CompanyIntroduction.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                startActivity(new Intent(context,CompanyIntroductionActivity.class));
                AllPublic.linkH5(activity, activity,"公司介绍", Constants.ABUT);
            }
        });
        ll_call.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ActionSheet.showSheet(AboutActivity.this,"联系我们", AboutActivity.this, AboutActivity.this);
            }
        });
    }
    @Override
    public void onClick(int whichButton) {
        // TODO Auto-generated method stub
        switch (whichButton) {
            case 0:
//                showToast("点击了清除");
                //打电话
                try {
                    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+ Constants.contactUp));
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }catch (ActivityNotFoundException exception){
                    ToastUtils.showShortToast(context,"当前设备不支持此功能");
                }


                break;

            case 1:
//                showToast("点击了取消");
                break;

            default:
                break;
        }

    }

    @Override
    public void onCancel(DialogInterface dialog) {
        // TODO Auto-generated method stub
//        showToast("取消");
    }
//    private void showToast(CharSequence charSequence) {
//        Toast.makeText(this, charSequence, Toast.LENGTH_SHORT).show();
//    }
}
